package com.ruoyi.rocky.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.rocky.domain.PcProxyAccount;
import com.ruoyi.rocky.service.PcProxyAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/proxyAccount")
@AllArgsConstructor
@Api(tags = "代理账号管理")
public class PcProxyAccountController extends BaseController {
    @Autowired
    private PcProxyAccountService pcProxyAccountService;

    /**
     * 查询代理账号列表
     */
    @ApiOperation(value = "查询代理账号列表")
    @GetMapping("/sel/list")
    public TableDataInfo list(PcProxyAccount pcProxyAccount) {
        startPage();
        List<PcProxyAccount> list = pcProxyAccountService.selectPcProxyAccountList(pcProxyAccount);
        return getDataTable(list);
    }

//    /**
//     * 导出代理账号列表
//     */
//    @ApiOperation(value = "查询产品列表")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, PcProxyAccount pcProxyAccount)
//    {
//        List<PcProxyAccount> list = pcProxyAccountService.selectPcProxyAccountList(pcProxyAccount);
//        ExcelUtil<PcProxyAccount> util = new ExcelUtil<PcProxyAccount>(PcProxyAccount.class);
//        util.exportExcel(response, list, "代理账号数据");
//    }

    /**
     * 获取代理账号详细信息
     */
    @ApiOperation(value = "根据id查询代理账号信息")
    @GetMapping(value = "/sel/{id}")
    public R getInfo(@PathVariable("id") Long id) {
        return R.ok(pcProxyAccountService.selectPcProxyAccountById(id));
    }

    /**
     * 新增代理账号
     */
    @ApiOperation(value = "新增代理账号")
    @PostMapping("/add")
    public R add(@RequestBody PcProxyAccount pcProxyAccount) {
        return R.ok(pcProxyAccountService.insertPcProxyAccount(pcProxyAccount));
    }

    /**
     * 修改代理账号
     */
    @ApiOperation(value = "修改代理账号")
    @PutMapping("/edit")
    public R edit(@RequestBody PcProxyAccount pcProxyAccount) {
        return R.ok(pcProxyAccountService.updatePcProxyAccount(pcProxyAccount));
    }

    /**
     * 删除代理账号
     */
    @ApiOperation(value = "逻辑删除")
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids) {
        return R.ok(pcProxyAccountService.deletePcProxyAccountByIds(ids));
    }
}

